import http from '@/utils/request'

// 用户优惠券接口
interface UserCoupon {
    id: number
    userId: number
    couponId: number
    status: number
    receiveTime: string
    useTime: string
    createTime: string
    updateTime: string
    // 关联的优惠券信息
    coupon?: {
        id: number
        name: string
        type: number
        discount: string
        minPoint: string
        useScope: number
        startTime: string
        endTime: string
        status: number
    }
}

// 获取用户优惠券列表
export const getUserCouponList = (params: {
    pageNum: number
    pageSize: number
    userId?: number
    status?: number
}) => {
    return http.get('/coupon/api/user/list', params)
}

// 获取用户优惠券详情
export const getUserCouponDetail = (id: number) => {
    return http.get(`/coupon/api/user/${id}`)
}

// 更新用户优惠券状态
export const updateUserCoupon = (data: {
    id: number;
    userId: number;
    couponId: number;
    couponCode: string;
    status: number;
    orderNo?: string;
    useTime?: string;
}) => {
    return http.put('/coupon/api/user', data);
};
